package com.danhuang.cloud.danhuanguser.controller;


import com.danhuang.cloud.danhuangcore.entity.UserInfoDTO;
import com.danhuang.cloud.danhuangcore.model.DhRes;
import com.danhuang.cloud.danhuangcore.service.UserDubboService;
import com.danhuang.cloud.danhuanguser.service.UserService;
import lombok.AllArgsConstructor;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;

/**
 * @author huangwubin
 */
@RestController
@RequestMapping("/info")
@AllArgsConstructor
@Validated
@DubboService
public class UserController implements UserDubboService{

    private final UserService userService;


    @Override
    @PostMapping("/search")
    public DhRes searchOpenId( @NotBlank(message="openId不能为空") @RequestParam String openId){
        return userService.searchOpenId(openId);
    }

    @Override
    @PostMapping("/create")
    public DhRes createUser(@Valid @RequestBody UserInfoDTO userInfoDTO){
        return userService.createUser(userInfoDTO);
    }


}
